Community Curator/Source/TSWRes Game
local print = print print("Game Loading...") sleep(0) draw.setscreen(1) local GameT = {} GT = GameT Grid, Zoom = 16, 1 function Nil() end -- Resorces require("GameRes") Draw = require "TSWRes Draw" Stickers = require "TSWRes Stick" ObjRes = require "TSWRes Objects" PopitRes = require "TSWRes Popit" JSON = require "JSON" Strings = require "TSWRes Strings" Loader = require "TSWRes LoadProcess" Sandbox = require "TSWRes Sandbox" FS = require "ModuleFS" SizeX, SizeY = draw.getport() CG = collectgarbage local CG = CG local draw = draw CG() -- Game Stuff ObjTab = {nil, nil, nil, nil, nil} --local ObjTab = ObjTab LevelTab = {"Name" = "Unnamed Level", "Description" = "Add a description to this level.", "Icon" = "nil", "Labels" = {}} LuaCorTab = {} MyMoonLevels = {} -- For the My Moon Levels local LevelTab = LevelTab ChPtTab = {} LTV = 0 -- Level Thermometer Value MT = 2000 -- Max Themometer Value PopitOpen, PopitCuMenu = false, "Home" CurChPt = 1 -- Currently activated Checkpoint CamX, CamY = 0, 250 -- Camera Position LogicCoroutines = {} -- Coroutines PlayCol1, PlayCol2, PCBG = Draw.Col255(64, 64, 255), Draw.Col255(232, 64, 255), Draw.Col255(0,0,0) PlayCol1T = Col255(64, 64, 255, 255*.25) MagicMouthText = "" NoticeText = "" ThermoPus, TPS = 16, 0 draw.beginframe() Draw.BGs.Loading() draw.endframe() sleep(10) -- Other FR = 30 -- Frame Rate (FPS) GT.Vars = {} GT.Vars.CreatedLevels = 0 -- Creates an Object Table used for the Game function GT.CreObjTab(CorTab, X, Y, Size, TVal, Dynamic, Mat, RotRad) local OT = {} OT"CorTab" = CorTab OT"Attach" = {} OT"Stickers" = {} OT"X" = X OT"Y" = Y OT"Size" = Size OT"Weight" = Size*Size OT"Dynam" = Dynamic or #ObjTab >= 4 OT"RotRad" = RotRad or 0 OT"Mat" = Mat OT"TVal" = TVal or 0 OT"XVol" = 0 OT"YVol" = 0 OT"RVol" = 0 OT"Lethal" = nil OT"NoCollide" = (CorTab "Entrance" or CorTab "Checkpoint" or CorTab "LevelEdge") return OT end function GT.CreChPtTab(Type, MaxLives, Lives, Active, Link, X, Y) local OT = {} OT"CorTab" = Type OT"Lives" = Lives or ChPtLives(Type) OT"MaxLives" = MaxLives or Lives or ChPtLives(Type) OT"Link" = Link OT"Active" = Active or false OT"X" = X OT"Y" = Y return OT end function GT.CreStiTab(Sticker, X, Y, Size) local OT = {} OT"Sticker" = Sticker OT"X" = X or 0 OT"Y" = Y or 0 OT"Size" = Size or 256 return OT end function TRec(X1,Y1,X2,Y2,TX,TY) --print("TRec",X1,Y1,X2,Y2,TX,TY) if TX>=X1 and TX<=X2 then if TY>=Y1 and TY<=Y2 then return true end end return false end function MagicMouthTextRemove(TX, TY) local String = NoticeText or MagicMouthText local BoxHeight = Draw.TxtBoxHeight(String) local Close = TRec(98, 24, SizeX - 98, 24 + BoxHeight, TX, TY) if Close then if NoticeText ~= "" then NoticeText = "" else MagicMouthText = "" end end end function GetTouch(TX,TY) return TX,TY end function CamMove(TX,TY) local TDirH, TDirV = TDPad(64, SizeY-96, TX, TY) CamX, CamY = CamX + TDirH, CamY + TDirV end function SacMove(TX,TY) Sac = ObjTab6 local TDirH, TDirV = TDPad(64, SizeY-96,TX,TY) Sac"X" = Sac"X" + TDirH if TDirV > 0 and Sac"YVol" > -.1 and Sac"YVol" < .4 then Sac"Y" = Sac"Y" -2 Sac"YVol" = -8 print("Sackboy Jump") end end function TDPad(DX,DY,TX,TY) local TSz=32 local LSz=TSz*2 local XSz=TSz*3 local U=TRec(DX+TSz, DY, DX+LSz, DY+TSz, TX, TY) local D=TRec(DX+TSz, DY+LSz, DX+LSz, DY+XSz, TX, TY) local L=TRec(DX, DY+TSz, DX+TSz, DY+LSz, TX, TY) local R=TRec(DX+LSz, DY+TSz, DX+XSz, DY+LSz, TX, TY) if U then return 0, 10 elseif D then return 0, -10 elseif L then return -10, 0 elseif R then return 10, 0 else return 0, 0 end end function GT.OutOfLives() draw.beginframe() draw.clear(draw.black) draw.endframe() draw.waittouch() PlayerOutOfLives = true end -- Builds the Blank Level function GT.BlankLevel() ObjTab = {} ChPtTab = {} LevelTab = {"Name" = "Unnamed Level", "Description" = "Add a description to this level."} LevelTab"WaterLevel" = 12 ObjTab1 = GT.CreObjTab("LevelEdge", -10000, 0, 30000) ObjTab2 = GT.CreObjTab("LevelEdge", -10000, -40000, 30000) ObjTab3 = GT.CreObjTab("LevelEdge", -30000, -10000, 30000) ObjTab4 = GT.CreObjTab("LevelEdge", 10000, -10000, 30000) ObjTab5 = GT.CreObjTab("Entrance", 48, -48, 32, 10, false) ObjTab6 = GT.CreObjTab("Sackboy", 48, -48, 32, 10, true) ObjTab7 = GT.CreObjTab("Square", 48, -48, 32, 10, true) local Tag = ObjTab7 local Stick = Tag"Stickers" Stick1 = GT.CreStiTab("LBPPick", 0, 0, 16) ChPtTab1 = GT.CreChPtTab("Entrance", 3, 3, true, 5, 48, -48) GT.FixIncLTV() end --[GT.BlankLevel() ObjTab = {} ChPtTab = {} LevelTab = {["Name" = "Unnamed Level", "Description" = "Add a description to this level."} ObjTab1 = GT.CreObjTab("LevelEdge", -10000, 0, 30000) ObjTab2 = GT.CreObjTab("LevelEdge", -10000, -40000, 30000) ObjTab3 = GT.CreObjTab("LevelEdge", -30000, -10000, 30000) ObjTab4 = GT.CreObjTab("LevelEdge", 10000, -10000, 30000) ObjTab5 = GT.CreObjTab("Sackboy", 48, -48, 128, 10, true) GT.FixIncLTV() end]] -- Object Related Stuff -- function GT.SackDie() local CurCheck = ChPtTabCurChPt local Sac = ObjTab6 CurCheck"Lives" = CurCheck"Lives" - 1 print(CurCheck"Lives", CurCheck"MaxLives", CurCheck"Lives"/CurCheck"MaxLives") if 0 > CurCheck"Lives" then GT.OutOfLives() end Sac"X" = CurCheck"X" Sac"Y" = CurCheck"Y" end -- Gets the value of the Thermometer. function GT.FixIncLTV() LTV = 0 for k,v in ipairs(ObjTab) do LTV = LTV+v"TVal" end end function DrThV() return LTV/MT end -- Play Mode function GT.PlayMode() end --function CorTest() LuaCorTab1 = ""--[[]] --LogicCoroutines1 = coroutine.create(CorTest) --GT.PlayMode = GT.TestMode require "TSWRes Game1" require "TSWRes Game2" require "TSWRes Game3" require "TSWRes Game4" require "TSWRes GameCM" StoryRes = require "TSWRes Story" require "TSWRes Community" LoaderTab.LoadFullProfile() if Startup nil then GT.Menu() end return GameT